<?php

class Common{

	/*

	$dm: danh sach mang can tao select

	$nameSelect: ten cua select



	*/

	public static function createSelect(array $dm,$nameSelect,$selected=-1,$addAllOption="NO",$valueAddAll=0,$nameEvent=""){
		$str="";
		// kiem tra $dm co rong khong
		if (count($dm)>=1){
			if (strcmp($nameEvent,'')!=0){
				$str.="<select name=\"".$nameSelect."\" onchange=\"".$nameEvent."\">";
			} else 	$str.="<select name=\"".$nameSelect."\">";
			if (strcmp($addAllOption,"YES")==0){
				$str.="<option value=\"".$valueAddAll."\">  Tất cả </option>";
			}
			foreach($dm as $key){
				if ($key->getMa()==$selected){			
					 $str.="<option value=\"".$key->getMa()."\" selected >".$key->getTen()."</option>";
				} else  $str.="<option value=\"".$key->getMa()."\">".$key->getTen()."</option>";
			}
			$str.="</select>";
		}		
		return $str;
	}
}


?>